package com.bruce.codeFactory.Thread.designMode.Balking;

import java.util.Random;

/**
 * @author luotuan
 * @Description
 * @create 2019-03-07 22:07
 **/
public class ChangeThread extends Thread {
    private FileData fileData;
    private Random random = new Random();

    public ChangeThread(String name, FileData fileData) {
        super(name);
        this.fileData = fileData;
    }

    @Override
    public void run() {
        try {
            for (int i = 0; i < 20; i++) {
                fileData.change("change " + i);
                Thread.sleep(random.nextInt(1000));
                fileData.save();
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
